<?php

$bugToVerify = $_POST['bugID'];

require_once('database2.php');

$query = 	"SELECT b.bugID,b.Priority,b.Description,b.Status, e1.Name AS EName, e1.Email AS EEmail, e1.Phone AS EPhone, e2.Name AS OName, e2.Email AS OEmail, e2.Phone AS OPhone, p.projectName AS PName,b.DateAssigned,b.DateClosed
				FROM BugMaster b
					INNER JOIN EmployeeMaster e1
						ON b.Assignee = e1.employeeID
					INNER JOIN EmployeeMaster e2
						ON b.Owner = e2.employeeID
					INNER JOIN ProjectMaster p
						ON b.projectID = p.projectID
						WHERE b.bugID='$bugToVerify'";	
		
		
$query2 = "SELECT comID, bugID, e3.Name AS SName, Text, date
			FROM CommentMaster c
				INNER JOIN EmployeeMaster e3
				ON c.employeeID = e3.employeeID
			WHERE bugID = '$bugToVerify'
			ORDER BY date";
						
$bugviews = $db->query($query);		
$comviews = $db->query($query2);
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Bugsby Tracking</title>
<link href="stylesheets/group1Site.css" rel="stylesheet" type="text/css">
<link rel="icon" href="graphics/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="graphics/favicon.ico" type="image/x-icon">
<script src="scripts/jquery-1.7.1.js"></script>
<script src="scripts/imageSwap.js"></script>
</head>

<body>
<div id="wrapper">
<div id="banner"> <img src="graphics/banner1.png" height="90" width="730" alt="bugsby logo"> </div>
<div id="leftcolumn">
  <div id="nav">
    <ul>
      <li><a href="index.html"><img src="graphics/home.ico" border=0 height="36" width="36" alt="home icon">&nbsp;Home</a></li>
      <li><a href="buglist.php"><img src="graphics/Spider.ico" border=0 height="36" width="36" alt="bug list icon">&nbsp;Bug List</a></li>
      <li><a href="buginfo.html"><img src="graphics/info.png" border=0 height="36" width="36" alt="Info">&nbsp;Info</a></li>
      <li><a href="bugmail.html"><img src="graphics/Gmail.png" border=0 height="36" width="36" alt="feedback icon">&nbsp;Contact</a></li>
    </ul>
  </div>
  <!-- End Nav id --> 
</div>
<!-- End leftcolumn -->

<div id="content">
  <h1>Bugsby - Bug Details</h1>
  <p class="standardText">Below are the full bug details:</p>
  <table border="1">
    <?php foreach ($bugviews as $bugview) : ?>
    <tr>
      <td> Bug ID Number: </td>
      <td><?php echo $bugview['bugID']; ?></td>
    </tr>
    <tr>
      <td> Brief Description: </td>
      <td><?php echo $bugview['Description']; ?></td>
    </tr>
    <tr>
      <td> Project Name: </td>
      <td><?php echo $bugview['PName']; ?></td>
    </tr>
    <tr>
      <td> Bug Priority: </td>
      <td><?php echo $bugview['Priority']; ?></td>
    </tr>
    <tr>
      <td> Bug Status: </td>
      <td><?php echo $bugview['Status']; ?></td>
    </tr>
    <tr>
      <td> Employee Assigned: </td>
      <td><?php echo $bugview['EName']; ?></td>
    </tr>
    <tr>
      <td> Employee Email: </td>
      <td><?php echo $bugview['EEmail']; ?></td>
    <tr>
    <tr>
      <td> Employee Phone: </td>
      <td><?php echo $bugview['EPhone']; ?></td>
    </tr>
    <tr>
      <td> Project Manager: </td>
      <td><?php echo $bugview['OName']; ?></td>
    </tr>
    <tr>
      <td> PM Email: </td>
      <td><?php echo $bugview['OEmail']; ?></td>
    <tr>
    <tr>
      <td> PM Phone: </td>
      <td><?php echo $bugview['OPhone']; ?></td>
    </tr>
    <tr>
      <td> Date Assigned: </td>
      <td><?php echo $bugview['DateAssigned']; ?></td>
    </tr>
    <tr>
      <td> Date Completed: </td>
      <td><?php echo $bugview['DateClosed']; ?></td>
    </tr>
    <?php endforeach; ?>
  </table>
  <br />
  <p class="standardText">Bug Comments:</p>
  <table border="1">
    <tr>
      <th>Date</th>
      <th>Comment</th>
      <th>Submitted By</th>
    </tr>
    <?php foreach ($comviews as $comview) : ?>
    <tr>
      <td><?php echo $comview['date']; ?></td>
      <td><?php echo $comview['Text']; ?></td>
      <td><?php echo $comview['SName']; ?></td>
    </tr>
    <?php endforeach; ?>
  </table>
  <br />
  <table>
    <tr>
      <td><form action="buglist.php" method="post" >
          <input type="image" SRC="graphics/Spider.ico" width="48" height="48" ALT="Add Bug!" />
        </form>
      <td>
    </tr>
    <tr>
      <td><p>Return to Bug List</p></td>
    </tr>
  </table>
</div>
<hr>
<p>&nbsp;</p>
<div id="navGraphics">
<h2>Click on a Graphic to Choose an Option:</h2>
<table width="800" border="0">
  <tr>
    <td><a href="index.html"><img src="graphics/home.png" border=0 height="128" width="128" alt="homepage icon" rel="graphics/homeRed.png" class="rollover" /></a></td>
    <td><a href="buginfo.html"><img src="graphics/info.png" border=0 height="128" width="128" alt="information icon" rel="graphics/infoRed.png" class="rollover" /></a></td>
    <td><a href="bugmail.html"><img src="graphics/Gmail.png" border=0 height="128" width="128" alt="send email icon" rel="graphics/GmailRed.png" class="rollover" /></a></td>
  </tr>
  <tr>
    <td class="standardText">Bugsby Home</td>
    <td class="standardText">Information</td>
    <td class="standardText">Contact</td>
  </tr>
</table>
<table>
</div>
<p>&nbsp;</p>
<div id="footer"> Site Content: <a href="mailto:cs633group1@gmail.com">CS633 Group 1</a> </div>
<!-- End Footer -->
</div>
<!-- End Wrapper -->
</body>
</html>
